package com.bt7274.utils;

import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;

/**
 * @Data 2025/5/30 16:43
 * @Author hp
 * @Version 1.0
 * @Description IPUtil
 */

@Slf4j
public class IPUtil {
    @NotNull
    public static String getRequestIp(@NotNull HttpServletRequest request) {
        String realIp = request.getHeader("X-REAL-IP");
        if (realIp == null)
            realIp = request.getHeader("X-FORWARDED-FOR");
        if (realIp == null)
            realIp = request.getRemoteAddr();
        return realIp;
    }
}

